function checkUserName() {
    var username = document.myform.username.value;
    var usernametab = document.getElementById('usernametab');
    if(/^\w{3,12}$/.test(username)){
        usernametab.innerHTML = '√';
        usernametab.style.color = '#0a0';
        return true;
    }else{
        usernametab.innerHTML = '×';
        usernametab.style.color = '#f00';
        return false;
    }
}

function checkName() {
    var name = document.myform.name.value;
    var nametab = document.getElementById('nametab');
    if(/^[\u4e00-\u9fa5_a-zA-Z0-9]{2,18}$/.test(name)){
        nametab.innerHTML = '√';
        nametab.style.color = '#0a0';
        return true;
    }else{
        nametab.innerHTML = '×';
        nametab.style.color = '#f00';
        return false;
    }
}

function checkPass() {
    var userpass = document.myform.userpass.value;
    var passtab = document.getElementById('passtab');
    if(/^\w{3,12}$/.test(userpass)){
        passtab.innerHTML = '√';
        passtab.style.color = '#0a0';
        return true;
    }else{
        passtab.innerHTML = '×';
        passtab.style.color = '#f00';
        return false;
    }
}

function checkRePass(){
    var userpass = document.myform.userpass.value;
    var userrepass = document.myform.userrepass.value;
    var repasstab = document.getElementById('repasstab');
    if (userpass !== userrepass) {
        repasstab.innerHTML = '×';
        repasstab.style.color = '#f00';
        return false;
    } else {
        repasstab.innerHTML = '√';
        repasstab.style.color = '#0a0';
        return true;
    }
}

// 表单提交验证
function checkForm() {
    return checkUserName() && checkName() && checkPass() && checkRePass();
}